package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;
import cn.edu.cqupt.cxcy.dto.IndexImpl;
import cn.edu.cqupt.cxcy.dto.InvestorImpl;
import cn.edu.cqupt.cxcy.model.Project;
import cn.edu.cqupt.cxcy.util.Tools;
import cn.edu.cqupt.cxcy.util.Validate;

/**
 * 一个项目的详细信息
 * @author Dancer-mno
 * @date 2015年10月17日
 */
@SuppressWarnings("serial")
public class InveProInfo  extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html;charset=utf-8");
		String pro_id=req.getParameter("id");
		//System.out.println(pro_id);
		if(pro_id!=null)
		{Project one=new InvestorImpl().WhileShowOfOneProject(Integer.parseInt(pro_id));
		int pt_id=one.getTe_id();//项目所属的团队id
		
		String teamname=new InvestorImpl().returnTeamName(pt_id);
		String type=new InvestorImpl().ReturnproType(pt_id);
		//System.out.println(type);
		String progress="发展期";
		Map<String,String> pro=new InvestorImpl().returnTeamname(pt_id);
		Map<String,Object> project=new HashMap<String,Object>();
		project.put("pro_content",one.getP_content());
		project.put("pro_time",one.getP_ltime());
		project.put("pro_type",type);
		project.put("pro_teamname", teamname);
		project.put("pro_progress", progress);
		project.put("pro_logo", one.getP_logo());
		int acount=new InvestorImpl().returnacount(1, one.getP_id(), 2);
		if(acount!=0)
		project.put("pro_acount",acount);
		else
			project.put("pro_acount","暂无投资");
		project.put("pro_mail", pro.get("email"));
		project.put("pro_pname", pro.get("pro_pname"));
		project.put("pro_tel", pro.get("pro_tel"));
		JSONObject jsonObject = JSONObject.fromObject(project);
		PrintWriter out= resp.getWriter();
		out.print(jsonObject.toString());}
		else{
			PrintWriter out= resp.getWriter();
			out.print("无id");
		}
		
	}
}
